import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class LoginDaoHelper {

	public User getUser(String username) throws ClassNotFoundException, SQLException{
		String sql = "SELECT TEN_NGUOI_DUNG, MAT_KHAU FROM USERS WHERE TEN_NGUOI_DUNG=?";
		Connection con = DaoUtil.getConnection();
		PreparedStatement stm = con.prepareStatement(sql);
		stm.setString(1, username);
		ResultSet rs = stm.executeQuery();
		User user = new User("","");
		while(rs.next()){
			user.setUsername(rs.getString(0));
			user.setPassword(rs.getString(1));
		}
		DaoUtil.closeConnection(con);
		return user;
	}
}
